<?php

$params = array_merge(
    require(__DIR__ . '/../../common/config/params.php'),
    require(__DIR__ . '/../../common/config/params-local.php'),
    require(__DIR__ . '/params.php'),
    require(__DIR__ . '/params-local.php')
);

return [
    'id' => 'app-api',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'modules' => [
        'v1' => [
            'basePath' => '@app/modules/v1',
            'class' => 'api\modules\v1\Module'
        ],
        'backend' => [
            'basePath' => '@app/modules/backend',
            'class' => 'api\modules\backend\Module'
        ],

    ],
    'components' => [
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'viewPath' => '@common/mail',
            'useFileTransport' => false,
            'transport' => [
                'class' => 'Swift_SmtpTransport',
                'host' => 'smtp.exmail.qq.com',
                'username' => 'internal@supernovachina.com',
                'password' => 'MailLoginSuperNovaChina1211',
                'port' => '465',
                'encryption' => 'ssl',
            ],
            'messageConfig' => [
                'charset' => 'UTF-8',
                'from' => ['internal@supernovachina.com' => 'internal@supernovachina.com']
            ],
        ],
        'user' => [
            'identityClass' => '',
            'enableAutoLogin' => true,
            'enableSession' => false,
        ],
        // 'log' => [
        //     'traceLevel' => YII_DEBUG ? 3 : 0,
        //     'targets' => [
        //         [
        //             'class' => 'yii\log\FileTarget',
        //             'levels' => ['error', 'warning'],
        //         ],
        //     ],
        // ],
        'urlManager' => [
            'enablePrettyUrl' => true,
            'enableStrictParsing' => true,
            'showScriptName' => false,
            'rules' => [
                [
                    'class' => 'yii\rest\UrlRule',
                    'controller' => [
                        'v1/account'
                    ],
                    'tokens' => [
                        '{id}' => '<id:\\w+>'
                    ],
                    'extraPatterns' => [
                        'GET info' => 'info',
                    ]
                ],
                [
                    'class' => 'yii\rest\UrlRule',
                    'controller' => [
                        'backend/account',
                        'backend/member'
                    ],
                    'tokens' => [
                        '{id}' => '<id:\\w+>'
                    ],
                    'extraPatterns' => [
                        'GET info' => 'info',
                        'POST batch' => 'batch'
                    ],
                ]
            ],
        ],
        'authManager' => [
            'class' => 'yii\rbac\DbManager', //使用数据库RBAC
            'itemTable' => 'vt_auth_item', //权限列表
            'assignmentTable' => 'vt_auth_assignment', //权限分配表
            'itemChildTable' => 'vt_auth_item_child', //权限父子关联表
            'ruleTable' => 'vt_auth_rule', //权限父子关联表
            // 'defaultRoles' => ['user'], //默认角色
        ],
        'request' => [
            'parsers' => [
                'application/json' => 'yii\web\JsonParser',
                'text/json' => 'yii\web\JsonParser',
            ],
            'cookieValidationKey' => 'true',     //
        ],

        'i18n' => [
            'translations' => [
                'app*' => [
                    'class' => 'yii\i18n\PhpMessageSource',   //使用php文件保存信息
                    'basePath' => '@app/messages',  //php文件保存位置
                    //'sourceLanguage' => 'en',
                    'fileMap' => [
                        'app' => 'app.php',
                        'app/error' => 'error.php',
                    ],
                ],
                'yii*' => [
                    'class' => 'yii\i18n\PhpMessageSource',   //使用php文件保存信息
                    'basePath' => '@yii/messages',  //php文件保存位置
                    //'sourceLanguage' => 'en',
                    'fileMap' => [
                        'yii' => 'yii.php',
                        'yii/error' => 'error.php',
                    ],
                ],
            ],
        ],
    ],

    'params' => $params,
];
